package com.igeek.javase.relation.game;

/**
 * @author chenmin
 * 2023/7/13 17:36
 * @description TODO
 */
public class Monster extends Role{

    public Monster() {
    }

    public Monster(String name, int level, int blood, int power, int defence, String kind) {
        super(name, level, blood, power, defence, kind);
    }

    //基本攻击方法
    @Override
    public void attack(Role role){
        //英雄的失血量 = 怪兽的攻击力 - 英雄的防御力
        int blood = this.getPower() - role.getDefence();
        if(blood>=0){
            role.setBlood(role.getBlood() - blood);
            System.out.println("英雄本回合失血量："+blood+"，剩余血量："+role.getBlood());
        }else{
            System.out.println("此回合攻击无效");
        }
    }


}
